@extends("public.main")
@section("content")
<div style="margin-left:200px;">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 分类管理 <span class="c-gray en">&gt;</span> 分类列表</nav>
    <div class="page-container">
        <div class="cl pd-5 bg-1 bk-gray "> <span class="l"><a class="btn btn-primary radius"  href="/admin/time/add"><i class="Hui-iconfont">&#xe600;</i> 添加时间</a></span> </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                <tr class="text-c">
                    <th width="40">ID</th>
                    <th width="100">时间设置</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($data['data']))
                @foreach($data['data'] as $k => $v)
                <tr class="text-c va-m">
                    <td>{{ $v['id'] }}</td>
                    <td>{{ $v['time'] }}</td>
                    <td class="td-manage"><a style="text-decoration:none" class="ml-5" href="/admin/time/edit/{{ $v['id']}}" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a><a style="text-decoration:none" class="ml-5"  onclick="deletearticle(this,{{$v['id'] }})" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
                </tr>
                @endforeach
                @else
                <tr class="text-c va-m">暂无数据</tr>
                @endif
                </tbody>
            </table>
            <div id="pagelist" style="float:right;margin-top:10px">
                {!! $data['data']->appends(['type' => $data['type']])->render() !!}
            </div>
        </div>
    </div>
</div>
@endsection

<script>
    /*产品-删除*/
    function deletearticle(obj,id){
        var token = "{{csrf_token()}}";
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/admin/time/del',
                data:{id:id,_token:token},
                dataType: 'json',
                success: function(data){
                    if(data.status == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>